Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@smithy/middleware-retry
Advanced tools
[![NPM version](https://img.shields.io/npm/v/@smithy/middleware-retry/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-retry) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-retry.svg)](https://www.npmjs.com/package/@smithy
@smithy/middleware-retry is a middleware package for the AWS SDK for JavaScript (v3) that provides retry functionality. It allows you to automatically retry failed requests based on customizable retry strategies, which can help improve the reliability and resilience of your applications.
Standard Retry Strategy
The StandardRetryStrategy provides a default retry strategy that retries failed requests with exponential backoff and jitter. This is useful for handling transient errors and improving the reliability of your application.
const { StandardRetryStrategy } = require('@smithy/middleware-retry');
const retryStrategy = new StandardRetryStrategy();
// Use the retry strategy in a client configuration
const client = new SomeAWSClient({
region: 'us-west-2',
retryStrategy
});
Custom Retry Strategy
You can create a custom retry strategy by extending the RetryStrategy class and implementing your own logic for determining when to retry and how many attempts to make. This allows you to tailor the retry behavior to your specific needs.
const { RetryStrategy } = require('@smithy/middleware-retry');
class CustomRetryStrategy extends RetryStrategy {
shouldRetry(error) {
// Custom logic to determine if the request should be retried
return error.retryable;
}
getMaxAttempts() {
// Custom logic to determine the maximum number of retry attempts
return 5;
}
}
const customRetryStrategy = new CustomRetryStrategy();
// Use the custom retry strategy in a client configuration
const client = new SomeAWSClient({
region: 'us-west-2',
retryStrategy: customRetryStrategy
});
Adaptive Retry Strategy
The AdaptiveRetryStrategy dynamically adjusts the retry behavior based on the observed success and failure rates of requests. This can help optimize the retry behavior for different network conditions and improve overall performance.
const { AdaptiveRetryStrategy } = require('@smithy/middleware-retry');
const adaptiveRetryStrategy = new AdaptiveRetryStrategy();
// Use the adaptive retry strategy in a client configuration
const client = new SomeAWSClient({
region: 'us-west-2',
retryStrategy: adaptiveRetryStrategy
});
axios-retry is a plugin for the Axios HTTP client that adds automatic retry functionality. It allows you to configure retry strategies, including exponential backoff and custom retry logic. Compared to @smithy/middleware-retry, axios-retry is designed specifically for use with Axios and may not offer the same level of integration with AWS SDK for JavaScript (v3).
retry is a general-purpose retry library for JavaScript that provides a flexible API for implementing retry logic. It supports various retry strategies, including exponential backoff and custom retry logic. While it is not specifically designed for use with the AWS SDK, it can be used to implement retry functionality in a wide range of applications.
promise-retry is a library that provides retry functionality for promise-based operations. It allows you to configure retry strategies and handle transient errors in asynchronous code. Like retry, it is a general-purpose library and can be used in various contexts, but it does not offer the same level of integration with the AWS SDK as @smithy/middleware-retry.
See @smithy/util-retry for retry behavior and configuration.
See also: AWS Documentation: Retry behavior.
FAQs
[![NPM version](https://img.shields.io/npm/v/@smithy/middleware-retry/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-retry) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-retry.svg)](https://www.npmjs.com/package/@smithy
We found that @smithy/middleware-retry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.